from core.basehandler import BaseHandler
from core.room import Room
from core.support import set_cutscene, get_game
from core.action import Action
from items.latte import Latte

class Starbucks(Room):
    def __init__(self, room_id):
        Room.__init__(self, room_id)
        self.add_action(SkipLatte)
        self.add_action(PurchaseLatte)
    
    def get_description(self):
        desc = '''
        You enter Starbucks.  While grateful to not find any undergrads in line 
        you are amazed to find the cute barista is now a zombie and is chanting the word 'brains' 
        over and over. But oddly enough, the Zombie is still serving drinks ...
        '''
        return desc
    
    def get_image(self):
        return 'Barista-Oil.jpg'

class StarbucksHandler(BaseHandler):
    def get_room_class(self):
        return Starbucks

class PurchaseLatte(Action):
    def __init__(self):
        Action.__init__(self, "purchaselatte")
    
    def get_description(self):
        return "Ask Zombie Barista for a Latte"
    
    def do_action(self,game,room,request):
        game = get_game()
        player = game.get_player()
        player.add_item(Latte())
        set_cutscene("Thank you for you order......brains!")
    
    def is_enabled(self):
        return not 'Latte' in get_game().get_player().inventory
    
    def get_method(self):
        return "post"

class SkipLatte(Action):
    def __init__(self):
        Action.__init__(self, "skiplatte")
    
    def get_description(self):
        return "Return to Second Floor Hallway"
    
    def get_destination(self):
        return 'secondfloorhallway'
    
    def get_method(self):
        return "get"
